class LazyMan {
  constructor(name) {
    this.name = name;
    this.time = '';
    this.task = [];
    console.log(`Hi! This is ${name}!`);
  }

  sleep(time) {
    console.log(`Wake up after ${time}`);
    setTimeout(() => {
      this.runTask();
    }, time);
    return this;
  }

  runTask() {
    let task = this.task.shift();
    if(!task) {
      return;
    }
    task()
    this.runTask();
  }

  eat(str) {
    this.task.push(function() {
      console.log(`Eat ${str}`);
    })
    return this;
  }
}


function _lazy(name) {
  return new LazyMan(name)
}

_lazy('kardel').sleep(10000).eat('dinner').eat('super')
// _lazy('kardel').sleep(5000).eat('moon')